// POSITIVE PARTISANSHIP
gen PPID = party_id
recode PPID 6=0 4=0
recode PPID (*=0) if pid_strength == 1
recode PPID (*=.) if party_id == 7 // Drop people who selected "other" party

gen HAVEPPID = 1 if PPID != .
recode HAVEPPID (1=0) if PPID == 0

gen LIBPPID = 0 if PPID != .
recode LIBPPID (0=1) if PPID == 1
gen CONPPID = 0 if PPID != .
recode CONPPID (0=1) if PPID == 2
gen NDPPPID = 0 if PPID != .
recode NDPPPID (0=1) if PPID == 3
gen GRPPID = 0 if PPID != .
recode GRPPID (0=1) if PPID == 5
gen NOPPID = 1 if HAVEPPID == 0
recode NOPPID (.=0) if HAVEPPID == 1

// NEGATIVE PARTISANSHIP
gen HAVENPID = 0 if vote_today != .
recode HAVENPID (0=1) if not_vote_1 == 1 & party_like_lib < 50
recode HAVENPID (0=1) if not_vote_2 == 1 & party_like_cons < 50
recode HAVENPID (0=1) if not_vote_3 == 1 & party_like_ndp < 50
recode HAVENPID (0=1) if not_vote_5 == 1 & party_like_gr < 50

gen LIBNPID = 0 if HAVENPID != .
recode LIBNPID (0=1) if not_vote_1 == 1 & party_like_lib < 50
gen CONNPID = 0 if HAVENPID != .
recode CONNPID (0=1) if not_vote_2 == 1 & party_like_cons < 50
gen NDPNPID = 0 if HAVENPID != .
recode NDPNPID (0=1) if not_vote_3 == 1 & party_like_ndp < 50
gen GRNPID = 0 if HAVENPID != .
recode GRNPID (0=1) if not_vote_5 == 1 & party_like_gr < 50
gen NONPID = 1 if HAVENPID == 0
recode NONPID (.=0) if HAVENPID == 1

gen COUNTNPID = LIBNPID + CONNPID + NDPNPID + GRNPID

// Eliminate NPID if they list the party they voted for
drop if LIBNPID == 1 & voted_party == 1
drop if CONNPID == 1 & voted_party == 2
drop if NDPNPID == 1 & voted_party == 3
drop if GRNPID == 1 & voted_party == 5
// Eliminate if NPID matches PPID
drop if PPID == 1 & LIBNPID == 1
drop if PPID == 2 & CONNPID == 1
drop if PPID == 3 & NDPNPID == 1
drop if PPID == 5 & GRNPID == 1

// Rename and rescale the personality variables
gen HONESTY = S_HH/100
gen EMOTION = S_EM/100
gen EXTRA = S_EX/100
gen AGREE = S_A/100
gen CONSC = S_C/100
gen OPEN = S_O/100

// Variable for typology
// 1 = neither, 2, = positive, 3 = negative, 4 = closed
gen typology = 1 if HAVENPID != . & HAVEPPID != .
recode typology (*=2) if HAVENPID == 0 & HAVEPPID == 1
recode typology (*=3) if HAVENPID == 1 & HAVEPPID == 0
recode typology (*=4) if HAVENPID == 1 & HAVEPPID == 1

gen positive = 0 if typology != .
recode positive (0=1) if typology == 2  
gen negative = 0 if typology != . 
recode negative (0=1) if typology == 3
gen open = 0 if typology != . 
recode open (0=1) if typology == 1
gen closed = 0 if typology != . 
recode closed (0=1) if typology == 4

// Control variables
gen ideol = left_right_1/10
gen female = 1 if sex == 0
recode female (.=0) if sex == 1
gen vismin = 1 if race < 8
recode vismin (1=0) if race == 7
gen unied = 1 if educat != .
recode unied (1=0) if educat < 4
gen west = 0 if prov < 11
recode west (0=1) if prov == 6 | prov == 3 | prov == 4 | prov == 5
gen east = 0 if prov < 11
recode east (0=1) if prov == 7 | prov == 8 | prov == 9 | prov == 10

********************************************************************************
// RESULTS
********************************************************************************
// Descriptives and correlation matrix (in appendix)
********************************************************************************
summ HONESTY EMOTION EXTRA AGREE CONSC OPEN if HONESTY != . & EMOTION != . & EXTRA != . & AGREE != . & CONSC != . & OPEN != .  
corr HONESTY EMOTION EXTRA AGREE CONSC OPEN if HONESTY != . & EMOTION != . & EXTRA != . & AGREE != . & CONSC != . & OPEN != .  

********************************************************************************
// Stage 1 of analysis: Background on Canada
********************************************************************************
// S Rates and distribution of NPID and PPID (by party)
summ HAVENPID HAVEPPID if HAVENPID != . & HAVEPPID != . // What share of people have the two?
tab COUNTNPID if HAVEPPID != . // What share has multiple NPID?
summ LIBNPID CONNPID NDPNPID GRNPID if HAVEPPID != . // Distribution of NPID
tab PPID if HAVENPID != . & HAVEPPID != . // distribution of PPID

// Table 1: Cross-tabs of NPID and PPID (both binary and by party)
tab HAVENPID HAVEPPID if HAVENPID != . & HAVEPPID != . // Cross-tab of the two
//tab HAVENPID PPID, col // Do Positive partisans have different rates of NPID? // YUP... Liberal are less likely to hold NPID
summ COUNTNPID // What is the average # of parties people hold NPID towards?

//Table 2: Tab of NPID and PPID - be sure to discuss rates of PPID towards different parties AND rates of NPID towards different parties
tab NONPID PPID
tab LIBNPID PPID 
tab CONNPID PPID 
tab NDPNPID PPID 
tab GRNPID PPID 

********************************************************************************
********************************************************************************
// Stage 2 of analysis - theory testing
********************************************************************************
// Figure 1: Correlates of having NPID and having PPID
logit HAVEPPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit HAVENPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
// Appendix/supplementary analysis to see who has multiple NPID
nbreg COUNT HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east // count model

// Figure 2: Correlates of the typologies of NPID
logit positive HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit negative HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit open HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit closed HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)

// Figure 3: Correlates of NPID and PPID towards specific parties
// PPID
logit LIBPPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit CONPPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit NDPPPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit GRPPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)

// NPID
logit LIBNPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit CONNPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit NDPNPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
logit GRNPID HONESTY EMOTION EXTRA AGREE CONSC OPEN ideol age female unied vismin west east
margins, dydx(*)
